package com.ibeeking.gmc.global.g.rest.controller.v1.feign;

import com.ibeeking.gmc.global.api.common.dto.OauthClientDTO;
import com.ibeeking.gmc.global.g.rest.service.IClientService;
import com.ibeeking.gmc.global.service.common.bo.OauthClientBO;
import com.ibeeking.nematos.utils.bean.BeanUtil;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @ClassName BunkInfoController控制器
 * @Description OAuth2.0客户端
 * @Author ibeeking
 * @Date 2020-10-22 10:34
 **/
@RestController
@RequestMapping("/g/oauth2/client/feign/v1")
public class ClientFeignController {

    @Resource
    private IClientService clientServiceImpl;

    /**
     * 通过clientId查询授权client
     *
     * @param clientId clientId
     * @return
     */
    @PostMapping(value = "/queryByClientId/{clientId}")
    public OauthClientDTO queryByClientId(@PathVariable String clientId) {
        OauthClientBO oauthClientBO = clientServiceImpl.queryByClientId(clientId);
        if (null == oauthClientBO) {
            return null;
        }
        return BeanUtil.convertBean(oauthClientBO, OauthClientDTO.class);
    }
}